<template>
  <div >
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮件"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间">
      </el-table-column>

    </el-table>
<!--    分页-->
    <el-pagination
      background
      layout="prev, pager, next"
      align="right"
      :total="totals"
      :page-size = "pageSize"
      :current-page = "correntPage"
      @current-change = "pageList">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'MyTable',
  data () {
    return {
      tableData: [],
      totals: 10000,
      correntPage: 1,
      pageSize : 5

    }
  },
  mounted() {
    this.list();

  },
  methods:{
    pageList(current){
      this.correntPage = current
      this.list();
    },
    list() {
      // fastmock 的接口地址https://www.fastmock.site/mock/235e399a9852840201281edc3380c5f1/pethome/depe/list
      // axios 请求
     this.$http.post("/depe/list",{"currentPage":this.correntPage,"pageSize":this.pageSize})
              .then(Result =>{
                this.tableData = Result.data.data;
                this.totals = Result.data.totals;

              }).catch(Result=>{
                // 请求失败
       alert("业务失败！")
     })


      // this.tableData = [{
      //   date: '2016-05-02',
      //   name: '王小虎',
      //   address: '上海市普陀区金沙江路 1518 弄'
      // }, {
      //   date: '2016-05-04',
      //   name: '王小虎',
      //   address: '上海市普陀区金沙江路 1517 弄'
      // }, {
      //   date: '2016-05-01',
      //   name: '王小虎',
      //   address: '上海市普陀区金沙江路 1519 弄'
      // }, {
      //   date: '2016-05-03',
      //   name: '王小虎',
      //   address: '上海市普陀区金沙江路 1516 弄'
      // }]
    }
  }

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
